package com.will.yuaiagent.tools;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import java.io.IOException;

/**
 * @author will
 * @since 2025/7/13 18:42
 * 网页抓取工具
 */
public class WebScrapingTool {


    @Tool(description = "Scrape the content of web page")
    public String scrapeWebPage(@ToolParam(description = "URL of the web page to scrape") String url) {
        // Implement web scraping logic here
        Document document = null;
        try {
            document = Jsoup.connect(url).get();
        } catch (IOException e) {
            return "Error fetching web page: " + e.getMessage();
        }
        return document.html();
    }

}
